package com.zhengke.controller.cwhs;

import com.zhengke.common.object.Result;
import com.zhengke.service.cwhs.GoodsSaleCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * *******************************
 * 创建时间：2020/1/1 22:39
 * 项目名称：tvmall-parent
 * 文件名称：GoodsSaleCountController.java
 * 类说明：  商品销售统计controller
 *
 * @author 王鑫
 * @version 1.0
 * *******************************
 */
@Controller
@RequestMapping("count")
public class GoodsSaleCountController {

    @Autowired
    private GoodsSaleCountService service;

    /**
     * 查询商品分类销售统计信息
     *
     * @return
     */
    @RequestMapping("querySalesCount.do")
    public String querySalesCountPage() {

        return "cwhs/salesCount";
    }

    /**
     * 查询商品分类销售统计信息
     *
     * @return
     */
    @RequestMapping("querySalesCountMsg.do")
    @ResponseBody
    public Result querySalesCount(HttpServletRequest request, ModelMap map, int page, int limit) {
        String startDate = request.getParameter("startDate");
        String endDate = request.getParameter("endDate");

        Result rs = null;
        try {
            rs = service.querySaleCount(startDate, endDate, page, limit);
            map.put("list", rs);
            System.out.println(rs);

            return rs;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result();
    }
}
